package com.lancoo.znbkxx.teacher.aibkGenerateTestPaper.aibkReviewTestPaper.aibkQuesReviewZW

import com.lancoo.znbkxx.teacher.aibkTestCoach.aibkTools.LancooMethod
import com.lancoo.znbkxx.teacher.aibkTestCoach.kBase.KBaseFragment
import android.text.Html
import android.view.View
import androidx.appcompat.app.AppCompatActivity
import com.lancoo.znbkxx.teacher.R
import com.lancoo.znbkxx.teacher.aibkGenerateTestPaper.aibkReviewTestPaper.QuesReviewInforIndexHelp.getChildListBean
import com.lancoo.znbkxx.teacher.aibkTestCoach.networkRequest.entity.TestPaperReviewInfor
import com.lancoo.znbkxx.teacher.utils.WebStyleUtils
import com.lancoo.znbkxx.teacher.widget.CustomTextViewToPicture
import kotlinx.android.synthetic.main.aibk_adapter_item_itemanalysis.view.*
import kotlinx.android.synthetic.main.aibk_adapter_item_itemanswer_zw.view.*
import kotlinx.android.synthetic.main.aibk_adapter_item_itemscore.view.*
import kotlinx.android.synthetic.main.aibk_adapter_item_word_stuanswer_zw.view.*
import kotlinx.android.synthetic.main.aibk_fragment_child_zw_analysis_word.view.*

class QuesReviewChildFragmentWord(
        val activity: AppCompatActivity,
        val testPaperReviewInfor: TestPaperReviewInfor,
        val index_A: Int,
        val index_B: Int,
        val index_C:Int
) : KBaseFragment() {

    private var rootView: View? = null

    override fun createLayout(): Int {
        return R.layout.aibk_fragment_child_zw_analysis_word
    }

    override fun initView(view: View?) {
        rootView = view

        //显示序号
        val itemSortIndex = getChildListBean(testPaperReviewInfor, index_A, index_B, index_C).ItemList[0].ItemSortIndex
        rootView!!.TvQuesNumber.text = "$itemSortIndex. "

        //隐藏得分项显示
        rootView!!.LlItemScore.visibility = View.GONE

        //隐藏学生作答区域
        rootView!!.LlStuAnswer.visibility = View.GONE

        //参考范文
        var childAnswer = getChildListBean(testPaperReviewInfor, index_A, index_B, index_C).ChildAnswer
        // 显示范文单词个数
        var textInputWordCount = LancooMethod.getKeyCount(childAnswer!!.trim(), " ") + 1
        rootView!!.TvItemWordCount.text = Html.fromHtml(
                activity.resources.getString(R.string.aibk_zw_word_count_blue,
                        textInputWordCount
                )
        )
        //显示范文
        WebStyleUtils.showWebViewCssStyle(activity,
                rootView!!.WvItemAnswer,
                childAnswer,
                false)

        //答案解析
        var childAnalysis = getChildListBean(testPaperReviewInfor, index_A, index_B, index_C).ChildAnalysis
        CustomTextViewToPicture(activity,rootView!!.TvItemAnalysis,childAnalysis)
    }

}